<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="6" :xs="24">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>个人信息</span>
          </div>
          <div>
            <div class="text-center">
              <userAvatar />
            </div>
            <ul class="list-group list-group-striped">
              
              <li class="list-group-item">
                <i class="el-icon-user"></i> <!-- 用户图标 -->用户名称：
                <p class="pull-right">{{ user.userName }}</p>
              </li>
             <el-divider></el-divider>
              <li class="list-group-item">
                <svg-icon icon-class="phone" />手机号码：
                <div class="pull-right">{{ user.phonenumber }}</div>
              </li>
              <el-divider></el-divider>
              <li class="list-group-item">
                <svg-icon icon-class="email" />用户邮箱：
                <div class="pull-right">{{ user.email }}</div>
              </li>
              <el-divider></el-divider>
              <li class="list-group-item">
                <svg-icon icon-class="tree" />所属部门：
                <div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div>
              </li>
              <el-divider></el-divider>
              <li class="list-group-item">
                <svg-icon icon-class="peoples" />所属角色：
                <div class="pull-right">{{ roleGroup }}</div>
              </li>
              <el-divider></el-divider>
              <li class="list-group-item">
                <svg-icon icon-class="date" />创建日期：
                <div class="pull-right">{{ user.createTime }}</div>
              </li>
              <el-divider></el-divider>
            </ul>
          </div>
        </el-card>
      </el-col>
      <el-col :span="18" :xs="24">
        <el-card>
          <div slot="header" class="clearfix">
            <span>基本资料</span>
          </div>
          <el-tabs v-model="activeTab">
            <el-tab-pane label="基本资料" name="userinfo">
              <!-- <userInfo :user="user" /> -->
              <el-form :model="formData" label-width="80px">
                  <el-form-item label="用户名">
                    <el-input v-model="formData.username"></el-input>
                  </el-form-item>
                  <el-form-item label="邮箱">
                    <el-input v-model="formData.email"></el-input>
                  </el-form-item>
                  <el-form-item label="密码">
                    <el-input type="password" v-model="formData.password"></el-input>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="updateProfile">更新个人信息</el-button>
                </el-form-item>
              </el-form>






            </el-tab-pane>
            <el-tab-pane label="修改密码" name="resetPwd">
              <!-- <resetPwd /> -->
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
// import userAvatar from "./userAvatar";
// import userInfo from "./userInfo";
// import resetPwd from "./resetPwd";
// import { getUserProfile } from "@/api/system/user";

export default {
  name: "Profile",
  // components: { userAvatar, userInfo, resetPwd },
  // components:{userAvatar},
  data() {
    return {
      formData: {
        username: '', // 用户名
        email: '', // 邮箱
        password: '' // 密码
      },
      user: {
        userName:"lihao",
        phonenumber:"111",
        email:"1234",
        dept:"计算机",
        roleGroup:"12",
        cretaeTime:"12-12-12"
      },
      roleGroup: {},
      postGroup: {},
      activeTab: "userinfo"
    };
  },
  created() {
    this.getUser();
  },
  methods: {
    updateProfile() {
      // 更新个人信息的逻辑
      console.log('更新个人信息：', this.formData);
    },
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
      });
    }
  }
};
</script>
<style>
   ul{
    list-style: none;
   }
   .list-group-item{
    display: flex;
    font-size: 14px;
    /* padding: 5px; */
   }
   hr{
    background-color: #CCCCCC;
    border: none;
    height: 1px;

   }
   .app-container{
    margin:15px
   }
</style>
